package edu.nf.project.services.process.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import edu.nf.project.entitys.entity.employeeAndCustomerInformation.convention.CustomerInfo;
import edu.nf.project.entitys.entity.storeOperation.convention.operate.RefundRequest;
import edu.nf.project.mappers.employeeAndCustomerInformation.convention.CustomerInfoMapper;
import edu.nf.project.services.process.RefundProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @author CSY
 * @date 2025 - 06 - 24
 * 会员卡退款
 */
@Component("memberCard")
public class MemberCardRefund implements RefundProcess {
    @Autowired
    private CustomerInfoMapper customerInfoMapper;

    @Override
    public void refund(RefundRequest refundRequest) {
        Integer uId = refundRequest.getUId();
        BigDecimal amount = refundRequest.getActualAmount();
        if (uId == null || amount == null) {
            throw new IllegalArgumentException("退款请求参数不合法");
        }
        customerInfoMapper.updateSurplus(uId, amount);
    }
}
